# Based on Win64 mozconfig
CROSS_COMPILE=1

ac_add_options --enable-application=browser

# Based on Win64 mozconfig
ac_add_options --target=arm-linux-gnueabihf
ac_add_options --with-toolchain-prefix=arm-linux-gnueabihf-
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-arm

mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
mk_add_options MOZILLA_OFFICIAL=1
mk_add_options BUILD_OFFICIAL=1

# From Mozilla MDN "Cross-compiling Mozilla" docs
ac_add_options --prefix=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf

# Failed attempt to prevent host includes from showing up
#CROSS_SYSROOT=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf
#export CFLAGS="-isysroot $CROSS_SYSROOT"
#export CXXFLAGS="-isysroot $CROSS_SYSROOT"
#export CPPFLAGS="-isysroot $CROSS_SYSROOT"

# New attempt to prevent host includes from showing up... passes configure but seems to break sqlite?
#CROSS_SYSROOT=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf
#FLAGS="-include $CROSS_SYSROOT/include/features.h"
#export CFLAGS="$FLAGS"
#export CXXFLAGS="$FLAGS"
#export CPPFLAGS="$FLAGS"

# Try to fix missing X libraries in configure
ac_add_options --x-libraries=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib
# And do the same for missing X headers
ac_add_options --x-includes=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include

# From Mozilla MDN "Compiling 32-bit Firefox on a Linux 64-bit OS" docs
# Should fix "error: Can't find header fontconfig/fcfreetype.h"
#ac_add_options --disable-freetypetest
#mk_add_options USE_FC_FREETYPE=0
#ac_add_options --disable-pango
# Trying random stuff here
mk_add_options MOZ_TREE_FREETYPE=1

# From https://wiki.mozilla.org/Mobile/Fennec/RaspberryPi/mozconfig2
export PKG_CONFIG_PATH=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/pkgconfig
#export CPPFLAGS="-I/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include -I/usr/include -I/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/include"
#export CFLAGS="-I/usr/include/arm-linux-gnueabihf"
#mk_add_options CPPFLAGS="$CPPFLAGS"
#mk_add_options  CFLAGS=$CFLAGS

# From https://wiki.mozilla.org/Mobile/Fennec/RaspberryPi/mozconfig2
FIX_LINK_LDFLAGS="-L/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib -Wl,-rpath-link=/var/tmp/dist/gcc-cross/arm-linux-gnueabihf/lib"
export LDFLAGS="$FIX_LINK_LDFLAGS"
LDFLAGS="$FIX_LINK_LDFLAGS"
export WRAP_LDFLAGS="$FIX_LINK_LDFLAGS"
mk_add_options LDFLAGS="$FIX_LINK_LDFLAGS"

# TODO: what does this do???
#ac_add_options --host=i686-linux-gnu

# From https://wiki.mozilla.org/Mobile/Fennec/RaspberryPi/mozconfig2
#export ac_cv_have_usable_wchar_option_v2="no"
#ac_add_options --enable-mobile-optimize
#ac_add_options --enable-system-ffi

ac_add_options --enable-optimize
#ac_add_options --disable-optimize
ac_add_options --enable-official-branding

# Let's support GTK3 for ESR60
ac_add_options --enable-default-toolkit=cairo-gtk3

ac_add_options --enable-tor-browser-update
ac_add_options --enable-signmar
ac_add_options --enable-verify-mar

ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-debug-symbols
ac_add_options --disable-maintenance-service
ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
# Let's make sure no preference is enabling either Adobe's or Google's CDM.
ac_add_options --disable-eme
#ac_add_options --disable-ctypes

# From https://wiki.mozilla.org/Mobile/Fennec/RaspberryPi/mozconfig2
# https://bugzilla.mozilla.org/show_bug.cgi?id=1452128 comment #32 says --disable-elf-hack is needed when cross-compiling ESR 60 for arm32 targets
ac_add_options --disable-elf-hack
#ac_add_options --enable-libjpeg-turbo

# From https://wiki.mozilla.org/Mobile/Fennec/RaspberryPi/mozconfig2
#ac_add_options --with-arm-kuser
#ac_add_options --with-thumb=toolchain-default
#ac_add_options --with-arch=armv6
#ac_add_options --with-float-abi=hard
#ac_add_options --with-thumb=no
#ac_add_options --with-fpu=vfp

# From https://archlinuxarm.org/packages/armv7h/firefox/files/PKGBUILD
ac_add_options --enable-optimize="-g -O2 -fno-schedule-insns"
ac_add_options --disable-stylo
